﻿using System;

class FallDown
{
    static void Main(string[] args)
    {
        System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

        int[,] fallDownMatrix = new int[8, 8];
        for (int row = 0; row < 8; row++)
        {
            int element = int.Parse(Console.ReadLine());
            for (int column = 7; column >= 0; column--)
            {
                fallDownMatrix[row, column] = element & 1;
                element >>= 1;
            }
        }

        for (int column = 0; column < 8; column++)
        {
            for (int row = 7; row > 0; row--)
            {
                if (fallDownMatrix[row, column] == 0)
                {
                    int rowForReplacing = 0;
                    while (fallDownMatrix[rowForReplacing,column] == 0 && rowForReplacing < row)
                    {
                        rowForReplacing++;
                    }
                    int temp = fallDownMatrix[rowForReplacing,column];
                    fallDownMatrix[rowForReplacing, column] = fallDownMatrix[row, column];
                    fallDownMatrix[row, column] = temp;
                }
            }
        }

        for (int row = 0; row < 8; row++)
        {
            int element = 0;
            for (int column = 7; column >= 0; column--)
            {
                element += (int)(fallDownMatrix[row, column] * Math.Pow(2,7-column));
                
            }
            Console.WriteLine(element);
        }
    }
}
